package com.ruoyi.system.api.service.impl;

import java.util.List;
import com.ruoyi.common.utils
        .DateUtils;
import com.ruoyi.system.api.ResponseWithData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.api.mapper.StAppVersionMapper;
import com.ruoyi.system.api.domain.StAppVersion;
import com.ruoyi.system.api.service.IStAppVersionService;
import com.ruoyi.common.core.text.Convert;

/**
 * APP版本管理Service业务层处理
 * 
 * @author ruoyi
 * @date 2020-04-05
 */
@Service
public class StAppVersionServiceImpl implements IStAppVersionService 
{
    @Autowired
    private StAppVersionMapper stAppVersionMapper;

    /**
     * 查询APP版本管理
     * 
     * @param id APP版本管理ID
     * @return APP版本管理
     */
    @Override
    public StAppVersion selectStAppVersionById(Long id)
    {
        return stAppVersionMapper.selectStAppVersionById(id);
    }

    /**
     * 查询APP版本管理列表
     * 
     * @param stAppVersion APP版本管理
     * @return APP版本管理
     */
    @Override
    public List<StAppVersion> selectStAppVersionList(StAppVersion stAppVersion)
    {
        return stAppVersionMapper.selectStAppVersionList(stAppVersion);
    }

    /**
     * 新增APP版本管理
     * 
     * @param stAppVersion APP版本管理
     * @return 结果
     */
    @Override
    public int insertStAppVersion(StAppVersion stAppVersion)
    {
        stAppVersion.setCreateTime(DateUtils.getNowDate());
        return stAppVersionMapper.insertStAppVersion(stAppVersion);
    }

    /**
     * 修改APP版本管理
     * 
     * @param stAppVersion APP版本管理
     * @return 结果
     */
    @Override
    public int updateStAppVersion(StAppVersion stAppVersion)
    {
        stAppVersion.setUpdateTime(DateUtils.getNowDate());
        return stAppVersionMapper.updateStAppVersion(stAppVersion);
    }

    /**
     * 删除APP版本管理对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteStAppVersionByIds(String ids)
    {
        return stAppVersionMapper.deleteStAppVersionByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除APP版本管理信息
     * 
     * @param id APP版本管理ID
     * @return 结果
     */
    @Override
    public int deleteStAppVersionById(Long id)
    {
        return stAppVersionMapper.deleteStAppVersionById(id);
    }

    @Override
    public ResponseWithData latestApp() {
        StAppVersion stAppVersion = stAppVersionMapper.latestApp();
        return new ResponseWithData().success(stAppVersion).code(200);
    }

    @Override
    public ResponseWithData<?> termsOfService(String versionCode) {
        StAppVersion stAppVersion = stAppVersionMapper.termsOfServiceByVersionCode(versionCode);
        return new ResponseWithData().success(stAppVersion).code(200);
    }
}
